local skel = fk.CreateSkill{
    name = "kt_ls__ziluan",
}

Fk:loadTranslationTable{
  ["kt_ls__ziluan"] = "恣乱",
  [":kt_ls__ziluan"] = "每个回合结束时，你弃置手牌中保存了三回合的牌并摸三张牌，你可以使用以此法获得的【杀】。",
  ["@kt_ls__ziluan-inhand"] = "恣乱",
  ["#kt_ls__ziluan"] = "恣乱：你可以使用以此法获得的【杀】",
}

skel:addEffect(fk.TurnEnd,{
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and not player:isKongcheng()
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local card = {}
    for _,cid in ipairs(player:getCardIds("h")) do
      local c = Fk:getCardById(cid)
      room:addCardMark(c,"@kt_ls__ziluan-inhand",1)
      if c:getMark("@kt_ls__ziluan-inhand") == 3 then
        table.insertIfNeed(card,cid)
      end
    end
    if #card == 0 then return end
    --
    room:throwCard(card,skel.name,player,player)
    local card2 = room:drawCards(player,3)
    if not table.find(card2,function (c) return Fk:getCardById(c).trueName == "slash" end) then return end
    --
    while #card2 > 0 and not player.dead do
      local use = room:askToUseRealCard(player, {
        pattern = "slash|.|.|hand|.|.|"..card2[1]..","..card2[2]..","..card2[3],-- 别问，问就是偷懒
        skill_name = skel.name,
        prompt = "#kt_ls__ziluan",
        extra_data = {
          not_passive = true,
        },
        cancelable = true,
      })
      if not use then
        return
      end
    end
  end,
})

return skel